package com.example.blog_system.service;

import com.example.blog_system.entity.ArticleInfo;
import com.example.blog_system.entity.CommentInfo;
import com.example.blog_system.entity.vo.ArticleInfoVO;
import com.example.blog_system.entity.vo.CommentInfoVO;
import com.example.blog_system.mapper.ArticleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:  文章服务层 调度对文章进行操作的映射层方法
 */
@Service
public class ArticleService {

    @Autowired
    private ArticleMapper articleMapper;

    public Integer del(Integer uid, Integer id,Integer state) {
        return articleMapper.del(uid, id,state);
    }

    public List<ArticleInfoVO> showArticleInfo(Integer id,Integer state) {
        return articleMapper.showArticleInfo(id,state);
    }

    public ArticleInfoVO showMyArticle(Integer uid, Integer id) {
        return articleMapper.showMyArticle(uid, id);
    }


    public int add(ArticleInfo text) {
        return articleMapper.add(text);
    }


    public Integer addRCount(Integer id) {
        return articleMapper.addRCount(id);
    }

    public ArticleInfoVO getBlog(Integer uid, Integer id) {
        return articleMapper.getBlogToModify(uid, id);
    }

    public Integer modify(Integer uid, ArticleInfoVO articleInfoVO) {
        return articleMapper.modify(uid, articleInfoVO);
    }

    public List<ArticleInfoVO> showBlogsByPage(Integer offset, Integer psize, String sort, String sortvalue) {
        return articleMapper.showBlogsByPage(offset, psize,sort,sortvalue);
    }

    public Integer getBlogCount() {
        return articleMapper.getBlogCount();
    }

    public ArticleInfoVO getContent(Integer id) {
        return articleMapper.getContent(id);
    }

    public Integer linkInfo(Integer uid, Integer id) {
        return articleMapper.linkInfo(uid, id);
    }

    public Integer unlike(Integer uid, Integer id) {
        return articleMapper.unlike(uid, id);
    }

    public Integer like(Integer uid, Integer id) {
        return articleMapper.like(uid, id);
    }

    public Integer addLike(Integer id) {
        return articleMapper.addLike(id);
    }

    public Integer delLike(Integer id,Integer num) {
        return articleMapper.delLike(id,num);
    }

    public Integer save(Integer id, ArticleInfo tmpArticle) {
        return articleMapper.save(id, tmpArticle);
    }

    public List<ArticleInfoVO> searchArticle(String option,String title) {
        return articleMapper.searchArticle(option,title);
    }

    public Integer delByAdmin(Integer id, Integer state) {
        return articleMapper.delByAdmin(id, state);
    }

    /**
     *  通过 博文id获取其作者id
     * @param id
     * @return
     */
    public Integer getUidById(Integer id) {
        return articleMapper.getUidById(id);
    }

    public Integer delLikeInfo(Integer id) {
        return articleMapper.delLikeInfo(id);
    }


    public List<CommentInfoVO> showComments(Integer id) {
        return articleMapper.showComments(id);
    }

    public Integer addComment(CommentInfo commentInfo) {
        return articleMapper.addComment(commentInfo);
    }

    public Integer delComment(Integer bid,Integer cid) {
        return articleMapper.delComment(bid,cid);
    }

    public void delCommentCount(Integer cid) {
        articleMapper.delCommentCount(cid);
    }

    public void addCommentCount(Integer bid) {
        articleMapper.addCommentCount(bid);
    }

    /**
     *  通过评论id获取其 发布评论者id
     * @param cid
     * @return
     */
    public Integer getUidByCid(Integer cid) {
        return articleMapper.getUidByCid(cid);
    }

    public List<ArticleInfoVO> showAuthorArticle(Integer id) {
        return articleMapper.showAuthorArticle(id);
    }

    public Integer collectInfo(Integer uid, Integer bid) {
        return articleMapper.collectInfo(uid, bid);
    }

    public Integer collect(Integer uid, Integer bid) {
        return articleMapper.collect(uid, bid);
    }

    public Integer addCollectionCount(Integer bid) {
        return articleMapper.addCollectionCount(bid);
    }

    public Integer uncollect(Integer uid, Integer bid) {
        return articleMapper.uncollect(uid, bid);
    }


    public Integer delCollectionCount(Integer bid) {
        return articleMapper.delCollectionCount(bid);
    }

    public List<ArticleInfoVO> showBlogsByCollection(Integer uid) {
        return articleMapper.showBlogsByCollection(uid);
    }

    public Integer getLikeNum(Integer uid, Integer id) {
        return articleMapper.getLikeNum(uid, id);
    }

    public void log(String username, String desc) {
        articleMapper.log(username, desc);
    }
}
